package com.java.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.java.po.Ask;
import com.java.po.AskMap;
import com.java.service.AskService;
import com.java.tool.AjaxJson;


@Controller
@CrossOrigin()
@RequestMapping(method=RequestMethod.POST)
public class AskController {
private AjaxJson ajaxJson;
	
	@Autowired
	private AskService askService;
	
	public AskController(){
		ajaxJson = new AjaxJson();
		//askService = new askServiceImpl();
	}
	
	@RequestMapping(value = "/insertAsk")
	public @ResponseBody AjaxJson insertAsk(@RequestBody Ask ask) throws Exception{
		ajaxJson = askService.insertAsk(ask);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/deleteAsk")
	public @ResponseBody AjaxJson deleteAsk(@RequestBody Ask ask) throws Exception{
		ajaxJson = askService.deleteAskById(ask);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/updateAsk")
	public @ResponseBody AjaxJson updateAsk(@RequestBody Ask ask) throws Exception{
		ajaxJson = askService.updateAskById(ask);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/findAsk")
	public @ResponseBody AjaxJson findAsk(@RequestBody AskMap askMap) throws Exception{
		ajaxJson = askService.findAllAsk(askMap);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/findAskByid")
	public @ResponseBody AjaxJson findAskByid(@RequestBody Ask ask) throws Exception{
		ajaxJson = askService.findAskByid(ask);
		return ajaxJson;
	}
}
